﻿<!DOCTYPE HTML>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
	<script src="../../static/js/jquery-3.5.1.min.js" th:src="@{/js/jquery-3.5.1.min.js}"></script>
	<link rel="stylesheet" type="text/css" href="../../static/h-ui/css/H-ui.min.css" th:href="@{/h-ui/css/H-ui.min.css}"/>
	<link rel="stylesheet" type="text/css" href="../../static/h-ui.admin/css/H-ui.admin.css" th:href="@{/h-ui.admin/css/H-ui.admin.css}"/>
	<link rel="stylesheet" type="text/css" href="../../static/lib/Hui-iconfont/1.0.8/iconfont.css" th:href="@{/lib/Hui-iconfont/1.0.8/iconfont.css}"/>
	<link rel="stylesheet" type="text/css" href="../../static/h-ui.admin/skin/default/skin.css" id="skin" th:href="@{/h-ui.admin/skin/default/skin.css}"/>
	<link rel="stylesheet" type="text/css" href="../../static/h-ui.admin/css/style.css" th:href="@{/h-ui.admin/css/style.css}"/>
	<link rel="stylesheet" href="../../static/Semantic-UI-master/dist/semantic.min.css" th:href="@{/Semantic-UI-master/dist/semantic.min.css}">
	<link rel="stylesheet" href="../../static/css/custom.css" th:href="@{/css/custom.css}">

<title>选课列表</title>
<link rel="stylesheet" href="../../static/lib/zTree/v3/css/zTreeStyle/zTreeStyle.css" type="text/css">
</head>
<script type="text/javascript" th:inline="javascript">
	$(function () {
		if(![[${session.admin}]]){
			alert("请先去登录")
			window.location.replace("/sy/syadmin/admin")
		}
	})

</script>
<body>
<div>
	<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 课程管理 <span class="c-gray en">&gt;</span> 选课列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
	<div class="page-container">
		<div class="text-c m-padded-t-middle">
			<div class="" style="padding-bottom: 10px">
				<input class="searchinput1 prompt" type="text" id="searchinput" placeholder="按用户id搜索...">
				<button class="searchbutton1 ui teal button" id="searchbutton"><i class="search icon"></i></button>
			</div>
		</div>
		<div class="cl pd-5 bg-1 bk-gray mt-20">

			<span class="r">共有数据：<strong th:text="${session.xkList.size()}" id="datanum">54</strong> 条</span> </div>
		<div class="mt-20">
			<table class="table table-border table-bordered table-bg table-hover table-sort">
				<thead>
					<tr class="text-c">
						<th width="40">用户ID</th>
						<th width="40">课程ID</th>
						<th width="60">用户名</th>
						<th width="100">课程名称</th>
						<th width="180">课程描述</th>
						<th width="100">操作</th>
					</tr>
				</thead>
				<tbody id="searchshow">
					<tr class="text-c va-m" th:each="xkObject:${session.xkList}">
						<td th:text="${xkObject.userId}">1</td>
						<td th:text="${xkObject.courseId}">1</td>
						<td th:text="${xkObject.userName}">sytest</td>
						<td th:text="${xkObject.courseName}">操作系统</td>
						<td th:text="${xkObject.courseDetails}">
							操作系统_清华大学(向勇、陈渝) https://github.com/chyyuu/os_course_info
						</td>
						<td class="td-manage"> <a style="text-decoration:none" class="ml-5" th:onClick="xkobject_del(this,[[${xkObject.userId}]],[[${xkObject.courseId}]])" href="javascript:;" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a></td>
					</tr>
				</tbody>
			</table>
		</div>
	</div>
</div>

<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="../../static/lib/layer/2.4/layer.js" th:src="@{/lib/layer/2.4/layer.js}"></script>
<script type="text/javascript" src="../../static/h-ui/js/H-ui.min.js" th:src="@{/h-ui/js/H-ui.min.js}"></script>
<script type="text/javascript" src="../../static/h-ui.admin/js/H-ui.admin.js" th:src="@{/h-ui.admin/js/H-ui.admin.js}"></script> <!--/_footer 作为公共模版分离出去-->
<script src="../../static/js/jquery-ui.min.js" th:src="@{/js/jquery-ui.min.js}"></script>
<script src="../../static/Semantic-UI-master/dist/semantic.min.js" th:src="@{/Semantic-UI-master/dist/semantic.min.js}"></script>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="../../static/lib/My97DatePicker/4.8/WdatePicker.js" th:src="@{/lib/My97DatePicker/4.8/WdatePicker.js}"></script>
<script type="text/javascript" src="../../static/lib/datatables/1.10.0/jquery.dataTables.min.js" th:src="@{/lib/datatables/1.10.0/jquery.dataTables.min.js}"></script>
<script type="text/javascript" src="../../static/lib/laypage/1.2/laypage.js" th:src="@{/lib/laypage/1.2/laypage.js}"></script>
<script type="text/javascript" src="../../static/lib/zTree/v3/js/jquery.ztree.all-3.5.min.js" th:src="@{/lib/zTree/v3/js/jquery.ztree.all-3.5.min.js}"></script>
<script type="text/javascript">

	//搜索
	$("#searchbutton").click(function () {
		var text = $("#searchinput").val();
		$.ajax({
			type: "get",
			cache: false,
			url: "/sy/xktable/search",
			data: {"searchstr":text},
			contenType: "application/json;charset=utf-8",
			success: function (data) {

				if(data.length==0){
					layer.msg('没有搜索到内容',{icon:0,time:2000});
				}else {
					$("#datanum").text(data.length);
					var htmls = '';

					for(let i=0; i<data.length; i++){
						var add ='<tr class="text-c va-m">\n' +
								'\t\t\t\t\t\t<td>'+data[i].userId+'</td>\n' +
								'\t\t\t\t\t\t<td>'+data[i].userId+'</td>\n' +
								'\t\t\t\t\t\t<td>'+data[i].userName+'</td>\n' +
								'\t\t\t\t\t\t<td>'+data[i].courseName+'</td>\n' +
								'\t\t\t\t\t\t<td>'+data[i].courseDetails+'</td>\n' +
								'\t\t\t\t\t\t<td class="td-manage"> <a style="text-decoration:none" class="ml-5" onClick="xkobject_del(this,'+data[i].userId+','+data[i].courseId+')" href="javascript:;" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a></td>\n' +
								'\t\t\t\t\t</tr>';


						htmls += add;
					}
					$("#searchshow").html(htmls);
				}
			},
			error: function (message) {
				layer.msg('请输入用户id',{icon:0,time:1000});
			}
		})

	})
/*选课-删除*/
function xkobject_del(obj,userid,couresid){
	layer.confirm('确认要删除吗？',function(index){
		$.ajax({
			type: 'POST',
			url: '/sy/xktable/deletexkObject',
			cache: false,
			data: {
				'userid':userid,
				'couresid':couresid
			},
			success: function(data){
				$(obj).parents("tr").remove();
				layer.msg('已删除!',{icon:1,time:1000});
			},
			error:function(data) {
				layer.msg('出错了',{icon:0,time:1000});
			},
		});		
	});
}
</script>
</body>
</html>